$(document).on('click', '.FQA-list .FQA-t', function () {
	$(this).parents("ul").find(".FQA-c").hide();
	$(this).parents("li").find(".FQA-c").show();
});


$(function () {
	var province_id = $("#province_id").attr('data-id');
	if(province_id){
		GetCity('province_id', 0, province_id);
	}
	var city_id = $("#city_id").attr('data-id');
	if(city_id){
		GetCity('city_id', province_id, city_id);
	}
	var county_id = $("#county_id").attr('data-id');
	if(county_id){
		GetCity('county_id', city_id, county_id);
	}

	$("#province_id").change(function(){
		GetCity('city_id', $("#province_id").val());
	})

	$("#city_id").change(function(){
		GetCity('county_id', $("#city_id").val());
	})
	
	 
	
	var verifys = $("input[verify]");//验证数组
	
	
	var _tipsMessage = {
		"company" : {
			prompt : "<i></i>请填写公司名称",
			err:"<i></i>请填写正确的公司名称",
			success :"<i></i>"
		}
		,
		"register_num" : {
			prompt : "<i></i>请填写社会信用代码",
			err:"<i></i>请填写正确的社会信用代码",
			success :"<i></i>"
		}
		,
		"establish_at" : {
			prompt : "<i></i>选择公司成立日期，如：2013-02-06",
			err:"<i></i>选择公司成立日期，如：2013-02-06",
			success :"<i></i>"
		}
		,
		"register_capital" : {
			prompt : "<i></i>请填写注册资本",
			err:"<i></i>请填写正确的注册资本",
			success :"<i></i>"
		}
		,
		"paid_capital" : {
			prompt : "<i></i>请填写实缴资本",
			err:"<i></i>请填写正确的实缴资本",
			success :"<i></i>"
		}
		,
		"business_scope" : {
			prompt : "<i></i>请填写经营范围",
			err:"<i></i>请填写正确的经营范围",
			success :"<i></i>"
		}
		,
		"price" : {
			prompt : "<i></i>请填写转让价格",
			err:"<i></i>请填写正确的转让价格",
			success :"<i></i>"
		}
		,
		"phone" : {
			prompt : "<i></i>请填写手机号",
			err:"<i></i>请填写正确的手机号",
			success :"<i></i>"
		}
		,
		"linkman" : {
			prompt : "<i></i>请填写联系人",
			err:"<i></i>请填写正确的联系人",
			success :"<i></i>"
		}
	}
	$("input[type=text]").focus(function(){
		$(this).addClass("on");
		if(typeof($(this).attr("verify"))!="undefined"){
			var _tips = $(this).parents("span.c").find(".tips");
			_tips.html(_tipsMessage[$(this).attr("verify")].prompt);
			_tips.removeClass("success err").addClass("prompt").fadeIn();
		}
	})
	
	$("input[type=text]").blur(function(){
		var _t = $(this);
		var verify = _t.attr("verify");
		if(typeof(verify)=="undefined"){
			_t.removeClass("on");
			return false
		};
		
		switch(_t.attr("verify")){
			case "company": 
				_verification(_t,function(o){
					if(o.attr("value")==""){
						return false;
					}else{
						return true;
					}
				},_tipsMessage["company"]);
				break;
			case "register_num": 
				_verification(_t,function(o){
					if(o.attr("value")==""){
						return false;
					}else{
						return true;
					}
				},_tipsMessage["register_num"]);
				break;
			case "establish_at": 
				_verification(_t,function(o){
					if(o.attr("value")==""){
						return false;
					}else{
						return true;
					}
				},_tipsMessage["establish_at"]);
				break;
			case "register_capital": 
				_verification(_t,function(o){
					if(o.attr("value")==""){
						return false;
					}else{
						return true;
					}
				},_tipsMessage["register_capital"]);
				break;
			case "paid_capital": 
				_verification(_t,function(o){
					if(o.attr("value")==""){
						return false;
					}else{
						return true;
					}
				},_tipsMessage["paid_capital"]);
				break;
			case "business_scope": 
				_verification(_t,function(o){
					if(o.attr("value")==""){
						return false;
					}else{
						return true;
					}
				},_tipsMessage["business_scope"]);
				break;
			case "price": 
				_verification(_t,function(o){
					if(o.attr("value")==""){
						return false;
					}else{
						return true;
					}
				},_tipsMessage["price"]);
				break;
		 
			case "phone":
				var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(16[0-9]{1})|(17[0-9]{1})|(19[0-9]{1})|(18[0-9]{1}))+\d{8})$/; 
				_verification(_t,function(o){
					if(o.attr("value")=="" || !myreg.test(o.attr("value"))){
						return false;
					}else{
						return true;
					}
				},_tipsMessage["phone"]);
				break;
			case "linkman": 
				reNum=/\d/;
				_verification(_t,function(o){
					if(o.attr("value")=="" || reNum.test(o.attr("value"))){
						return false;
					}else{
						return true;
					}
				},_tipsMessage["linkman"]);
				break; 
				
		}
	})
	
	$('#Agreement').click(function() {
		layer.open({
			type: 1,
			skin: 'layui-layer-molv',
			area: ['900px', '400px'],
			shadeClose: true, //点击遮罩关闭
			content: $(".Agreement").html(),
			title : "《快转网转让协议》"
		});
	 })
	 
	 $("input:radio[name='is_licenseplate']").change(function(){
		var v = $(this).val();
		if (v == 1){
			$(".licenseplate_desc").show();
		}else{
			$(".licenseplate_desc").hide();
		}
	});
	
	$("input:radio[name='is_patent']").change(function(){
		var v = $(this).val();
		if (v == 1){
			$(".patent_desc").show();
		}else{
			$(".patent_desc").hide();
		}
	});
	
	$("input:radio[name='apply_invoice']").change(function(){
		var v = $(this).val();
		if (v == 1){
			$("#ordinary").show();
			$("#ordinary_invoice").show();
			if($("input[name='tax_type']:checked").val() == 2){
				$("#special").show();
				$("#ordinary_invoice").hide();
			}
		}else{
			$("#ordinary").hide();
			$("#special").hide();
		}
	});
	$("input:radio[name='tax_type']").change(function(){
		var v = $(this).val();
		if (v == 1){
			$("#special").hide();
			$("#ordinary_invoice").show();
		}else if(v == 2){
			if($("input[name='apply_invoice']:checked").val() == 1){
				$("#special").show();
			}
		}
	});
	$("input:radio[name='bank_account']").change(function(){
		var v = $(this).val();
		if (v == 1){
			$(".bank_account").show();
		}else{
			$(".bank_account").hide();
		}
	});
	$("input:radio[name='tax_report']").change(function(){
		var v = $(this).val();
		if (v == 1){
			$("#tax").show();
		}else{
			$("#tax").hide();
		}
	});

	$("input:radio[name='price_type']").change(function(){
		var v = $(this).val();
		if (v == 3){
			$(".price_type_3").show();
		}else{
			$(".price_type_3").hide();
		}
	});
	
	$("input:radio[name='type']").change(function(){
		var v = $(this).val();
		if (v == 2){
			$(".company_assets").show();
			$(".is_empty_sell").show();
		}else{
			$(".company_assets").hide();
			$(".is_empty_sell").hide();
		}
	});
	
	$("input:radio[name='is_personnel_team']").change(function(){
		var v = $(this).val();
		if (v == 1){
			$(".personnel_team_desc").show();
		}else{
			$(".personnel_team_desc").hide();
		}
	});
	
	$("input:radio[name='is_product_inventory']").change(function(){
		var v = $(this).val();
		if (v == 1){
			$(".product_inventory_desc").show();
		}else{
			$(".product_inventory_desc").hide();
		}
	});
	
	$("input:radio[name='is_site_equipment']").change(function(){
		var v = $(this).val();
		if (v == 1){
			$(".site_equipment_desc").show();
		}else{
			$(".site_equipment_desc").hide();
		}
	});

	$("input:radio[name='is_business']").change(function(){
		var v = $(this).val();
		if (v == 1){
			$(".business_desc").show();
		}else{
			$(".business_desc").hide();
		}
	});
	
	
	$("#SaveSell").click(function(){
        var id = $("#id").val();
        var data = {};
        var token = $("#token").val();
        data.type = $("input[name='type']:checked").val();
        if(typeof(data.type) == 'undefined'){
        	layer.alert('请选择转让公司类型');
        	return;
        }
        
        data.company = $.trim($("#company").val());
        if(data.company == ''){
            layer.alert('请输入公司名称');
            return;
        }
        if(data.company.length<5){
			layer.alert('请正确填写公司名称');
        	return;
		}
        data.register_num = $("#register_num").val();
        if(data.register_num == ''){
            layer.alert('请输入注册号/统一社会信用代码');
            return;
        }
        if(data.register_num.length<5){
			layer.alert('请正确填写注册号/统一社会信用代码');
        	return;
		}
        data.register_currency = $("#register_currency").val();
        data.register_capital = $("#register_capital").val();
        if(data.register_capital == ''){
            layer.alert('请输入注册资本');
            return;
        }
        if(!checkRate(data.register_capital)){
			layer.alert('注册资本仅允许输入数字');
			return;
		}

        data.paid_currency = $("#paid_currency").val();
        data.paid_capital = $("#paid_capital").val();
		if(data.paid_capital != '' && !checkRate(data.paid_capital)){
			layer.alert('实缴资本仅允许输入数字');
			return;
		}

        data.establish_at = $("#establish_at").val();
        if(data.establish_at == ''){
            layer.alert('请选择成立日期');
            return;
        }
        data.province_id = $("#province_id").val();
        data.city_id = $("#city_id").val();
        data.county_id = $("#county_id").val();
        if(data.province_id == '' || data.city_id == '' || data.county_id ==''){
        	layer.alert('请选择完整注册地区');
            return;
        }
        data.business_scope = $("#business_scope").val();
        if(data.business_scope == ''){
        	layer.alert('请输入经营范围');
            return;
        }
        if(data.business_scope.length<5){
			layer.alert('请输入经营范围');
        	return;
		}

       // data.industy_id = $("#industy").data("value");
       // data.industy_info = $("#industy").val();
       // if(data.industy_id == '' || data.industy_info == ''){
        //	layer.alert('请选择公司所属行业');
        //    return;
       // }
        //标签
        var label = {};
        label['hot'] = [];
        $('input[name="hot"]:checked').each(function(i){
        	label['hot'].push($(this).val());
        });
        
        data.is_aptitude = $("input[name='is_aptitude']:checked").val();
        if(typeof(data.is_aptitude) == 'undefined'){
        	layer.alert('请选择是否有资质');
        	return;
        }
		if(data.is_aptitude == 1){
			label['aptitude'] = [];
			$("#label_list_aptitude input[type='hidden']").each(function(){
				label['aptitude'].push($(this).val());
			 });
			data.aptitude_desc = $("#aptitude_desc").val();
			if(data.aptitude_desc == ''){
	        	layer.alert('请填写资质描述');
	        	return;
	        }
	         if(data.aptitude_desc.length<2){
				layer.alert('请填写正确资质描述');
	        	return;
			}
			if(data.aptitude_desc.length>200){
				layer.alert('资质描述请勿超过200字');
	        	return;
			}
		}
		data.is_trademark = $("input[name='is_trademark']:checked").val();
		if(typeof(data.is_trademark) == 'undefined'){
        	layer.alert('请选择是否有商标');
        	return;
        }
		if(data.is_trademark == 1){
			label['trademark'] = [];
			$("#label_list_trademark input[type='hidden']").each(function(){
				label['trademark'].push($(this).val());
			 });
			data.trademark_desc = $("#trademark_desc").val();
			if(data.trademark_desc == ''){
	        	layer.alert('请填写商标描述');
	        	return;
	        }
	        if(data.trademark_desc.length<2){
				layer.alert('请填写正确商标描述');
	        	return;
			}
			if(data.trademark_desc.length>200){
				layer.alert('商标描述请勿超过200字');
	        	return;
			}
		}
		data.is_onlinestore = $("input[name='is_onlinestore']:checked").val();
		if(typeof(data.is_onlinestore) == 'undefined'){
        	layer.alert('请选择是否有网络资产');
        	return;
        }
		if(data.is_onlinestore == 1){
			label['onlinestore'] = [];
			$("#label_list_onlinestore input[type='hidden']").each(function(){
				label['onlinestore'].push($(this).val());
			 });
			data.onlinestore_desc = $("#onlinestore_desc").val();
			if(data.onlinestore_desc == ''){
	        	layer.alert('请填写网络资产描述');
	        	return;
			}
			if(data.onlinestore_desc.length<2){
				layer.alert('请填写正确网络资产描述');
	        	return;
			}
			if(data.onlinestore_desc.length>200){
				layer.alert('网络资产描述请勿超过200字');
	        	return;
			}
		}
		data.label = label;
		
		data.is_licenseplate = $("input[name='is_licenseplate']:checked").val();
		if(typeof(data.is_licenseplate) == 'undefined'){
        	layer.alert('请选择是否有车牌指标');
        	return;
        }
		if(data.is_licenseplate == 1){
			data.licenseplate_desc = $("#licenseplate_desc").val();
			if(data.licenseplate_desc == ''){
	        	layer.alert('请填写车牌描述');
	        	return;
	        }
	        if(data.licenseplate_desc.length<2){
				layer.alert('请填写正确车牌描述');
	        	return;
			}
			if(data.licenseplate_desc.length>200){
				layer.alert('车牌描述请勿超过200字');
	        	return;
			}
		}
		
		data.is_patent = $("input[name='is_patent']:checked").val();
		if(typeof(data.is_patent) == 'undefined'){
        	layer.alert('请选择是否有专利／著作权');
        	return;
        }
		if(data.is_patent == 1){
			data.patent_desc = $("#patent_desc").val();
			if(data.patent_desc == ''){
	        	layer.alert('请填写专利／著作权描述');
	        	return;
	        }
	        if(data.patent_desc.length<2){
				layer.alert('请填写正确专利著作描述');
	        	return;
			}

			if(data.patent_desc.length>200){
				layer.alert('专利／著作权描述请勿超过200字');
	        	return;
			}
		}
		
		if(data.type == 2){
			//实体公司判断
			data.is_personnel_team = $("input[name='is_personnel_team']:checked").val();
			if(typeof(data.is_personnel_team) == 'undefined'){
	        	layer.alert('请选择是否有人员团队');
	        	return;
	        }
			if(data.is_personnel_team == 1){
				data.personnel_team_desc = $("#personnel_team_desc").val();
				if(data.personnel_team_desc == ''){
					layer.alert('请具体描述公司人员团队详情');
		        	return;
				}
				if(data.personnel_team_desc.length<2){
					layer.alert('请正确描述公司人员团队详情');
		        	return;
				}
				if(data.personnel_team_desc.length>200){
					layer.alert('人员团队详情描述请勿超过200字');
		        	return;
				}
			}
			
			data.is_product_inventory = $("input[name='is_product_inventory']:checked").val();
			if(typeof(data.is_product_inventory) == 'undefined'){
	        	layer.alert('请选择是否有产品库存');
	        	return;
	        }
			if(data.is_product_inventory == 1){
				data.product_inventory_desc = $("#product_inventory_desc").val();
				if(data.product_inventory_desc == ''){
					layer.alert('请具体描述公司产品库存详情');
		        	return;
				}
				if(data.product_inventory_desc.length<2){
					layer.alert('请正确描述公司产品库存详情');
		        	return;
				}
				if(data.product_inventory_desc.length>200){
					layer.alert('产品库存详情描述请勿超过200字');
		        	return;
				}
			}

			data.is_site_equipment = $("input[name='is_site_equipment']:checked").val();
			if(typeof(data.is_site_equipment) == 'undefined'){
	        	layer.alert('请选择是否有场地／设备');
	        	return;
	        }
			if(data.is_site_equipment == 1){
				data.site_equipment_desc = $("#site_equipment_desc").val();
				if(data.site_equipment_desc == ''){
					layer.alert('请具体描述公司场地／设备详情');
		        	return;
				}
				if(data.site_equipment_desc.length<2){
					layer.alert('请正确描述公司场地／设备详情');
		        	return;
				}
				if(data.site_equipment_desc.length>200){
					layer.alert('场地／设备详情描述请勿超过200字');
		        	return;
				}
			}
			
			data.is_business = $("input[name='is_business']:checked").val();
			if(typeof(data.is_business) == 'undefined'){
	        	layer.alert('请选择是否有业务优势');
	        	return;
	        }  
			if(data.is_business == 1){
				data.business_desc = $("#business_desc").val();
				if(data.business_desc == ''){
					layer.alert('请具体描述业务优势');
		        	return;
				}
				if(data.business_desc.length<2){
					layer.alert('请正确描述业务优势');
		        	return;
				}
				if(data.business_desc.length>200){
					layer.alert('业务优势描述请勿超过200字');
		        	return;
				}
			}

			if(data.is_personnel_team == 0 && data.is_product_inventory == 0 && data.is_site_equipment == 0 && data.is_business == 0){
				data.type = 1
			} else {
				data.is_empty_sell = $("input[name='is_empty_sell']:checked").val();
				if(typeof(data.is_empty_sell) == 'undefined'){
		        	layer.alert('请选择是否接受空转');
		        	return;
		        }
			}
		}
		data.tax_report = $("input[name='tax_report']:checked").val();
		if(typeof(data.tax_report) == 'undefined'){
        	layer.alert('请选择税务是否报到/开业');
        	return;
        }
		if(data.tax_report == 1){
			data.tax_type = $("input[name='tax_type']:checked").val();
			if(typeof(data.tax_type) == 'undefined'){
	        	layer.alert('请选择纳税类型');
	        	return;
	        }
			data.tax_returns = $("input[name='tax_returns']:checked").val();
			if(typeof(data.tax_returns) == 'undefined'){
	        	layer.alert('请选择报税情况');
	        	return;
	        }
			data.apply_invoice = $("input[name='apply_invoice']:checked").val();
			if(typeof(data.apply_invoice) == 'undefined'){
	        	layer.alert('请选择是否申领过发票');
	        	return;
	        }
			if(data.apply_invoice == 1){
				if(data.tax_type == 2){
					data.special_invoice_dz = $("#special_invoice_dz").val();
					if(data.special_invoice_dz == ''){
			        	layer.alert('请选择专用发票单张面额');
			        	return;
			        }
					data.special_invoice_num = $("#special_invoice_num").val();
					if(data.special_invoice_num == '' || data.special_invoice_num == "0"){
			        	layer.alert('请输入专用发票每月可领份数');
			        	return;
			        }
			        if(!checkRate(data.special_invoice_num)){
						layer.alert('请正确输入专用发票每月可领份数');
						return;
					}
					data.ordinary_invoice_dz = $("#ordinary_invoice_dz").val();
					data.ordinary_invoice_num = $("#ordinary_invoice_num").val(); 
				} else {
					data.ordinary_invoice_dz = $("#ordinary_invoice_dz").val();
					data.ordinary_invoice_num = $("#ordinary_invoice_num").val();
					if(data.ordinary_invoice_dz == ''){
			        	layer.alert('请选择普通发票单张面额');
			        	return;
			        }
					if(data.ordinary_invoice_num == '' || data.ordinary_invoice_num == "0"){
			        	layer.alert('请输入普通发票每月可领份数');
			        	return;
			        }
					if(!checkRate(data.ordinary_invoice_num)){
						layer.alert('请正确输入普通发票每月可领份数');
						return;
					}
				}
			}
		}
		
		data.bank_account = $("input[name='bank_account']:checked").val();
		if(typeof(data.bank_account) == 'undefined'){
        	layer.alert('请选择银行账户');
        	return;
        }
		if(data.bank_account == 1){
			data.bank_account_status = $("input[name='bank_account_status']:checked").val();
			if(typeof(data.bank_account_status) == 'undefined'){
	        	layer.alert('请选择银行账户是否正常');
	        	return;
	        }
			data.bank_account_online = $("input[name='bank_account_online']:checked").val();
			if(typeof(data.bank_account_online) == 'undefined'){
	        	layer.alert('请选择是否有网银');
	        	return;
	        }
			data.bank_account_fwater = $("#bank_account_fwater").val();
			if(data.bank_account_fwater.length>200){
				layer.alert('银行流水情况描述请勿超过200字');
	        	return;
			}
		}

//		data.is_guarantee = $("input[name='is_guarantee']:checked").val();
//		if(typeof(data.is_guarantee) == 'undefined'){
//			layer.alert('请选择是否需要资金担保');
//        	return;
//        }
		
		data.price_type = $("input[name='price_type']:checked").val();
		if(typeof(data.price_type) == 'undefined'){
			layer.alert('请选择转让价格');
        	return;
        }
		if(data.price_type == 3){
			data.price = $("#price").val();
			if(data.price == ""){
				layer.alert('请输入转让价格');
	        	return;
			}
		}
		
		data.other_content = $("#other_content").val();
		if(data.other_content.length>200){
			layer.alert('其他信息描述请勿超过200字');
        	return;
		}
		data.phone = $("#phone").val();
		var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(16[0-9]{1})|(17[0-9]{1})|(19[0-9]{1})|(18[0-9]{1}))+\d{8})$/; 
		if(data.phone=="" || !myreg.test(data.phone)){
        	layer.alert('请输入联系电话');
            return;
        }
		data.linkman = $("#linkman").val();
		var reNum=/\d/;
		if(data.linkman == '' || reNum.test(data.linkman)){
        	layer.alert('请正确填写联系人,不能包含数字');
            return;
        } 
        if(data.linkman.length>5){
			layer.alert('请正确填写联系人,限5个字内');
        	return;
		}
		if($('#protocol').is(':checked')) { 
			$(this).attr('disabled',true);
	        $(".show_money").show();
			$("#gray_money").show(); 
		} else {
			layer.alert('请阅读并同意《快转网转让协议》');
            return;
		} 
	    
    });
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$("#SaveSell2").click(function(){
        var id = $("#id").val();
        var data = {};
        var token = $("#token").val();
        data.type = $("input[name='type']:checked").val();
        if(typeof(data.type) == 'undefined'){
        	layer.alert('请选择转让公司类型');
        	return;
        }
        
        data.company = $.trim($("#company").val());
        if(data.company == ''){
            layer.alert('请输入公司名称');
            return;
        }
        if(data.company.length<5){
			layer.alert('请正确填写公司名称');
        	return;
		}
        data.register_num = $("#register_num").val();
        if(data.register_num == ''){
            layer.alert('请输入注册号/统一社会信用代码');
            return;
        }
        if(data.register_num.length<5){
			layer.alert('请正确填写注册号/统一社会信用代码');
        	return;
		}
        data.register_currency = $("#register_currency").val();
        data.register_capital = $("#register_capital").val();
        if(data.register_capital == ''){
            layer.alert('请输入注册资本');
            return;
        }
        if(!checkRate(data.register_capital)){
			layer.alert('注册资本仅允许输入数字');
			return;
		}

        data.paid_currency = $("#paid_currency").val();
        data.paid_capital = $("#paid_capital").val();
		if(data.paid_capital != '' && !checkRate(data.paid_capital)){
			layer.alert('实缴资本仅允许输入数字');
			return;
		}

        data.establish_at = $("#establish_at").val();
        if(data.establish_at == ''){
            layer.alert('请选择成立日期');
            return;
        }
        data.province_id = $("#province_id").val();
        data.city_id = $("#city_id").val();
        data.county_id = $("#county_id").val();
        if(data.province_id == '' || data.city_id == '' || data.county_id ==''){
        	layer.alert('请选择完整注册地区');
            return;
        }
        data.business_scope = $("#business_scope").val();
        if(data.business_scope == ''){
        	layer.alert('请输入经营范围');
            return;
        }
        if(data.business_scope.length<5){
			layer.alert('请输入经营范围');
        	return;
		}

       // data.industy_id = $("#industy").data("value");
       // data.industy_info = $("#industy").val();
       // if(data.industy_id == '' || data.industy_info == ''){
        //	layer.alert('请选择公司所属行业');
        //    return;
       // }
        //标签
        var label = {};
        label['hot'] = [];
        $('input[name="hot"]:checked').each(function(i){
        	label['hot'].push($(this).val());
        });
        
        data.is_aptitude = $("input[name='is_aptitude']:checked").val();
        if(typeof(data.is_aptitude) == 'undefined'){
        	layer.alert('请选择是否有资质');
        	return;
        }
		if(data.is_aptitude == 1){
			label['aptitude'] = [];
			$("#label_list_aptitude input[type='hidden']").each(function(){
				label['aptitude'].push($(this).val());
			 });
			data.aptitude_desc = $("#aptitude_desc").val();
			if(data.aptitude_desc == ''){
	        	layer.alert('请填写资质描述');
	        	return;
	        }
	        if(data.aptitude_desc.length<2){
				layer.alert('请正确填写正确资质描述');
	        	return;
			}
			if(data.aptitude_desc.length>200){
				layer.alert('资质描述请勿超过200字');
	        	return;
			}
		}
		data.is_trademark = $("input[name='is_trademark']:checked").val();
		if(typeof(data.is_trademark) == 'undefined'){
        	layer.alert('请选择是否有商标');
        	return;
        }
		if(data.is_trademark == 1){
			label['trademark'] = [];
			$("#label_list_trademark input[type='hidden']").each(function(){
				label['trademark'].push($(this).val());
			 });
			data.trademark_desc = $("#trademark_desc").val();
			if(data.trademark_desc == ''){
	        	layer.alert('请填写商标描述');
	        	return;
	        }
	        if(data.trademark_desc.length<2){
					layer.alert('请正确填写商标描述');
		        	return;
				}
			if(data.trademark_desc.length>200){
				layer.alert('商标描述请勿超过200字');
	        	return;
			}
		}
		data.is_onlinestore = $("input[name='is_onlinestore']:checked").val();
		if(typeof(data.is_onlinestore) == 'undefined'){
        	layer.alert('请选择是否有网络资产');
        	return;
        }
		if(data.is_onlinestore == 1){
			label['onlinestore'] = [];
			$("#label_list_onlinestore input[type='hidden']").each(function(){
				label['onlinestore'].push($(this).val());
			 });
			data.onlinestore_desc = $("#onlinestore_desc").val();
			if(data.onlinestore_desc == ''){
	        	layer.alert('请填写网络资产描述');
	        	return;
			}
			 if(data.onlinestore_desc.length<2){
					layer.alert('请正确填写网络资产描述');
		        	return;
				}
			if(data.onlinestore_desc.length>200){
				layer.alert('网络资产描述请勿超过200字');
	        	return;
			}
		}
		data.label = label;
		
		data.is_licenseplate = $("input[name='is_licenseplate']:checked").val();
		if(typeof(data.is_licenseplate) == 'undefined'){
        	layer.alert('请选择是否有车牌指标');
        	return;
        }
		if(data.is_licenseplate == 1){
			data.licenseplate_desc = $("#licenseplate_desc").val();
			if(data.licenseplate_desc == ''){
	        	layer.alert('请填写车牌描述');
	        	return;
	        }
	        if(data.licenseplate_desc.length<2){
					layer.alert('请正确填写车牌描述');
		        	return;
				}
			if(data.licenseplate_desc.length>200){
				layer.alert('车牌描述请勿超过200字');
	        	return;
			}
		}
		
		data.is_patent = $("input[name='is_patent']:checked").val();
		if(typeof(data.is_patent) == 'undefined'){
        	layer.alert('请选择是否有专利／著作权');
        	return;
        }
		if(data.is_patent == 1){
			data.patent_desc = $("#patent_desc").val();
			if(data.patent_desc == ''){
	        	layer.alert('请填写专利／著作权描述');
	        	return;
	        }
	        if(data.patent_desc.length<2){
					layer.alert('请正确填写专利／著作权描述');
		        	return;
				}

			if(data.patent_desc.length>200){
				layer.alert('专利／著作权描述请勿超过200字');
	        	return;
			}
		}
		
		if(data.type == 2){
			//实体公司判断
			data.is_personnel_team = $("input[name='is_personnel_team']:checked").val();
			if(typeof(data.is_personnel_team) == 'undefined'){
	        	layer.alert('请选择是否有人员团队');
	        	return;
	        }
			if(data.is_personnel_team == 1){
				data.personnel_team_desc = $("#personnel_team_desc").val();
				if(data.personnel_team_desc == ''){
					layer.alert('请具体描述公司人员团队详情');
		        	return;
				}
				if(data.personnel_team_desc.length<2){
					layer.alert('请正确描述公司人员团队详情');
		        	return;
				}
				if(data.personnel_team_desc.length>200){
					layer.alert('人员团队详情描述请勿超过200字');
		        	return;
				}
			}
			
			data.is_product_inventory = $("input[name='is_product_inventory']:checked").val();
			if(typeof(data.is_product_inventory) == 'undefined'){
	        	layer.alert('请选择是否有产品库存');
	        	return;
	        }
			if(data.is_product_inventory == 1){
				data.product_inventory_desc = $("#product_inventory_desc").val();
				if(data.product_inventory_desc == ''){
					layer.alert('请具体描述公司产品库存详情');
		        	return;
				}
				if(data.product_inventory_desc.length<2){
					layer.alert('请正确描述公司产品库存详情');
		        	return;
				}
				if(data.product_inventory_desc.length>200){
					layer.alert('产品库存详情描述请勿超过200字');
		        	return;
				}
			}

			data.is_site_equipment = $("input[name='is_site_equipment']:checked").val();
			if(typeof(data.is_site_equipment) == 'undefined'){
	        	layer.alert('请选择是否有场地／设备');
	        	return;
	        }
			if(data.is_site_equipment == 1){
				data.site_equipment_desc = $("#site_equipment_desc").val();
				if(data.site_equipment_desc == ''){
					layer.alert('请具体描述公司场地／设备详情');
		        	return;
				}
				if(data.site_equipment_desc.length<2){
					layer.alert('请正确描述公司场地／设备详情');
		        	return;
				}
				if(data.site_equipment_desc.length>200){
					layer.alert('场地／设备详情描述请勿超过200字');
		        	return;
				}
			}

			data.is_business = $("input[name='is_business']:checked").val();
			if(typeof(data.is_business) == 'undefined'){
	        	layer.alert('请选择是否有业务优势');
	        	return;
	        } 
			if(data.is_business == 1){
				data.business_desc = $("#business_desc").val();
				if(data.business_desc == ''){
					layer.alert('请具体描述业务优势');
		        	return;
				}
				if(data.business_desc.length<2){
					layer.alert('请正确描述业务优势');
		        	return;
				}
				if(data.business_desc.length>200){
					layer.alert('业务优势描述请勿超过200字');
		        	return;
				}
			}
			
			if(data.is_personnel_team == 0 && data.is_product_inventory == 0 && data.is_site_equipment == 0 && data.is_business == 0){
				data.type = 1
			} else {
				data.is_empty_sell = $("input[name='is_empty_sell']:checked").val();
				if(typeof(data.is_empty_sell) == 'undefined'){
		        	layer.alert('请选择是否接受空转');
		        	return;
		        }
			}
		}
		data.tax_report = $("input[name='tax_report']:checked").val();
		if(typeof(data.tax_report) == 'undefined'){
        	layer.alert('请选择税务是否报到/开业');
        	return;
        }
		if(data.tax_report == 1){
			data.tax_type = $("input[name='tax_type']:checked").val();
			if(typeof(data.tax_type) == 'undefined'){
	        	layer.alert('请选择纳税类型');
	        	return;
	        }
			data.tax_returns = $("input[name='tax_returns']:checked").val();
			if(typeof(data.tax_returns) == 'undefined'){
	        	layer.alert('请选择报税情况');
	        	return;
	        }
			data.apply_invoice = $("input[name='apply_invoice']:checked").val();
			if(typeof(data.apply_invoice) == 'undefined'){
	        	layer.alert('请选择是否申领过发票');
	        	return;
	        }
			if(data.apply_invoice == 1){
				if(data.tax_type == 2){
					data.special_invoice_dz = $("#special_invoice_dz").val();
					if(data.special_invoice_dz == ''){
			        	layer.alert('请选择专用发票单张面额');
			        	return;
			        }
					data.special_invoice_num = $("#special_invoice_num").val();
					if(data.special_invoice_num == '' || data.special_invoice_num == "0"){
			        	layer.alert('请输入专用发票每月可领份数');
			        	return;
			        }
			        if(!checkRate(data.special_invoice_num)){
						layer.alert('请正确输入专用发票每月可领份数');
						return;
					}
					data.ordinary_invoice_dz = $("#ordinary_invoice_dz").val();
					data.ordinary_invoice_num = $("#ordinary_invoice_num").val(); 
				} else {
					data.ordinary_invoice_dz = $("#ordinary_invoice_dz").val();
					data.ordinary_invoice_num = $("#ordinary_invoice_num").val();
					if(data.ordinary_invoice_dz == ''){
			        	layer.alert('请选择普通发票单张面额');
			        	return;
			        }
					if(data.ordinary_invoice_num == '' || data.ordinary_invoice_num == "0"){
			        	layer.alert('请输入普通发票每月可领份数');
			        	return;
			        }
					if(!checkRate(data.ordinary_invoice_num)){
						layer.alert('请正确输入普通发票每月可领份数');
						return;
					}
				}
			}
		}
		
		data.bank_account = $("input[name='bank_account']:checked").val();
		if(typeof(data.bank_account) == 'undefined'){
        	layer.alert('请选择银行账户');
        	return;
        }
		if(data.bank_account == 1){
			data.bank_account_status = $("input[name='bank_account_status']:checked").val();
			if(typeof(data.bank_account_status) == 'undefined'){
	        	layer.alert('请选择银行账户是否正常');
	        	return;
	        }
			data.bank_account_online = $("input[name='bank_account_online']:checked").val();
			if(typeof(data.bank_account_online) == 'undefined'){
	        	layer.alert('请选择是否有网银');
	        	return;
	        }
			data.bank_account_fwater = $("#bank_account_fwater").val();
			if(data.bank_account_fwater.length>200){
				layer.alert('银行流水情况描述请勿超过200字');
	        	return;
			}
		}

//		data.is_guarantee = $("input[name='is_guarantee']:checked").val();
//		if(typeof(data.is_guarantee) == 'undefined'){
//			layer.alert('请选择是否需要资金担保');
//        	return;
//        }
		
		data.price_type = $("input[name='price_type']:checked").val();
		if(typeof(data.price_type) == 'undefined'){
			layer.alert('请选择转让价格');
        	return;
        }
		if(data.price_type == 3){
			data.price = $("#price").val();
			if(data.price == ""){
				layer.alert('请输入转让价格');
	        	return;
			}
		}
		
		data.other_content = $("#other_content").val();
		if(data.other_content.length>200){
			layer.alert('其他信息描述请勿超过200字');
        	return;
		}
		data.phone = $("#phone").val();
		var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(16[0-9]{1})|(17[0-9]{1})|(19[0-9]{1})|(18[0-9]{1}))+\d{8})$/; 
		if(data.phone=="" || !myreg.test(data.phone)){
        	layer.alert('请输入联系电话');
            return;
        }
		data.linkman = $("#linkman").val();
		var reNum=/\d/;
		if(data.linkman == '' || reNum.test(data.linkman)){
        	layer.alert('请正确填写联系人,不能包含数字');
            return;
        } 
        if(data.linkman.length>5){
			layer.alert('请正确填写联系人,限5个字内');
        	return;
		}
		if($('#protocol').is(':checked')) {
			layer.load(); 
			$(this).attr('disabled',true);
	        $.post('savesell2',{'id':id,'data':data,'_token':token},function(response){
	        	layer.closeAll('loading');
	        	$(this).removeAttr('disabled');
	            if(response.error){
	                layer.alert(response.msg);
	                return;
	            }
	            layer.alert(response.msg,function(){ 
	            	window.location.href = "/user/index.html";
	            });
	        },'json');
		} else {
			layer.alert('请阅读并同意《快转网转让协议》');
            return;
		} 
	  
		 
    });
	
	
})

//验证函数
function _verification(o,callback,s){
	var _Option = s;
	var _tips = o.parents("span.c").find(".tips");
	
	if(callback(o)){
		_tips.html(_Option.success);
		o.removeClass("on");
		_tips.removeClass("prompt err").addClass("success").fadeIn();
//		verifys = verifys.not(o);
	}else{
		o.addClass("on");
		_tips.html(_Option.err);
		_tips.removeClass("prompt success").addClass("err").fadeIn();
//		verifys = verifys.add(o);
	}
}

function checkRate(number) {
	var re = /^[0-9]+.?[0-9]*$/; //判断字符串是否为数字 //判断正整数 /^[1-9]+[0-9]*]*$/
	if (!re.test(number)) {
		return false;
	}
	return true;
}

function GetCity(id, pid, selected_id){
	$.get('/ajax/city.json',{'pid':pid},function(response){
		$("#"+id).html("<option value=\"\">---- 请选择 ----</option>");
		if(id == 'city_id'){
			$("#county_id").html("<option value=\"\">---- 请选择 ----</option>");	
		}
		$.each(response.data, function(i, n){
			if(id == 'province_id'){
				if(n['id'] != 36){
					if(n['id'] == selected_id){
						$("#"+id).append("<option value=" + n['id'] + " selected>" + n['city'] + "</option>");
					} else {
						$("#"+id).append("<option value=" + n['id'] + ">" + n['city'] + "</option>");
					}
				}
			}else{
				if(n['id'] == selected_id){
					$("#"+id).append("<option value=" + n['id'] + " selected>" + n['city'] + "</option>");
				} else {
					$("#"+id).append("<option value=" + n['id'] + ">" + n['city'] + "</option>");
				}
			}
		});
	},'json');
}